<extend file='../master'/>
<block name="content">
    <style>
        th{
            text-align: center;
        }
    </style>
    <ol class="breadcrumb" style="background-color: #f9f9f9;padding:8px 0;margin-bottom:10px;">
        <li>
            <a href="{{u('entry.index')}}"><i class="fa fa-cogs"></i>首页</a>
        </li>
        <li class="active">
            <a href="">
                订单管理</a>
        </li>
    </ol>
    <ul class="nav nav-tabs" role="tablist">
        <li class="active"><a href="#tab1">d订单管理</a></li>
    </ul>
    <form action="" method="post" onsubmit="return del()">
        <div class="panel panel-default">
            <div class="panel-body">
                <table class="table table-hover">
                    <thead>
                    <tr style="text-align: center">
                        <th width="80">编号</th>
                        <th>订单号</th>
                        <th width="100">订单价钱</th>
                        <th>订单时间</th>
                        <th>订单状态</th>
                        <th width="200">操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <foreach from="$ordersData" key="$k" value="$v">
                        <tr style="text-align: center" class="tr{{$v['oid']}}">
                            <td>{{$v['oid']}}</td>
                            <td>{{$v['number']}}</td>
                            <td>{{$v['total']}}</td>
                            <td>{{date('Y-m-d H:i:s',$v['time'])}}</td>
                            <td>{{$v['status']}}</td>
                            <td>
                                <div class="btn-group">
                                    <button data-toggle="dropdown" class="btn btn-primary btn-xs dropdown-toggle">操作 <span class="caret"></span></button>
                                    <ul class="dropdown-menu dropdown-menu-right">
                                        <li><a href="{{u('edit',['oid'=>$v['oid']])}}">编辑</a></li>
                                        <li class="divider"></li>
                                        <li><a href="JavaScript:;" onclick="del({{$v['oid']}})">删除</a></li>
                                    </ul>
                                </div>
                            </td>
                        </tr>
                    </foreach>
                    </tbody>
                </table>
            </div>
        </div>
    </form>
    <div class="pagination pagination-sm pull-right">
<!--        {{$page}}-->
    </div>
</block>
<script>
    function del(oid) {
        var obj = util.modal({
            title: '确定删除吗',//标题
            content: '',//内容
            footer: '<button type="button" class="btn btn-default " data-dismiss="modal">关闭</button><button type="button" class="btn btn-danger confirm" data-dismiss="modal">确认</button>',//底部
            width: 600,//宽度
            events: {
                confirm: function () {
                    //哪个元素上有.confirm类，被点击就执行这个回调
                    $.post("{{u('del')}}", {b: oid}, function (res) {
                        if (res.valid) {
                            util.message(res.message, "", 'success');
                            $(".tr" + oid).remove();
                        } else {
                            util.message(res.message, '', 'error');
                        }
                    }, 'json');
                    return false;
                }
            }
        });
        //显示模态框
        obj.modal('show');
    }
</script>
